package com.msl.debezium.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

//@Component
public class KafkaKerberosUtil implements ApplicationContextAware {

    private Logger logger = LoggerFactory.getLogger(KafkaKerberosUtil.class);


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        try {
            String basePath = System.getProperty("user.dir")+"\\conf";
            logger.info("basePath:"+basePath);
            System.setProperty("java.sercurity.auth.login.config", basePath + "\\kafka_client_jaas.conf");
            System.getProperties().put("java.security.krb5.conf", basePath + "\\krb5.conf");
            logger.info("=== fetch config files finish ===");

        }catch (Exception e){
            logger.error("fetch config files fail", e);
            throw new BeansException("fetch config files fail") {};
        }
    }
}
